<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>重置密码</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
            /*background: cadetblue;*/
        }

        #logo{
            height: 50px;
            left:25%;
            top:50px;
            position: absolute;
        }
        #aaa{
            height: 50px;
            left:25%;
            top:100px;
            position: absolute;
            margin-top: 20px;
        }
        #img{
            color:rgba(81, 203, 238, 1);
            text-decoration: none;
            font-size: 2.5em;

        }
        #zhuye{

            left:25%;
            top:200px;
            position: absolute;
        }
        #youxiang{
            height: 25px;
            width:300px;
            padding: 7px 5px;
            margin: 10px 0;
            display: block;
            font-size: 18px;
            border-radius: 5px;
            background: transparent;
            border: 1.5px solid #87CEFA;

        }
        #mima{
            height: 25px;
            width:300px;
            padding: 7px 5px;
            margin: 10px 0;
            display: block;
            font-size: 18px;
            border-radius: 5px;
            background: transparent;
            border: 1.5px solid #87CEFA;
        }
        #minghao{
            height: 25px;
            width:300px;
            padding: 7px 5px;
            margin: 10px 0;
            display: block;
            font-size: 18px;
            border-radius: 5px;
            background: transparent;
            border: 1.5px solid #87CEFA;
        }
        #shouji{
            height: 25px;
            width:300px;
            padding: 7px 5px;
            margin: 10px 0;
            display: block;
            font-size: 18px;
            border-radius: 5px;
            background: transparent;
            border: 1.5px solid #87CEFA;
        }
        #anniu{
            background: rgb(26, 188, 156);
            padding: 10px;
            font-size: 20px;
            display: block;
            width: 150px;
            border: none;
            color: #fff;
            border-radius: 5px;
            left:25%;
            position: absolute;
            cursor: pointer;
        }

    </style>
</head>
<body background="timg2.jpg">
<div id="logo">
    <a href="" id="img">酷睿影评</a>
</div>

<div id="aaa">
    <h2>
        酷睿欢迎你
    </h2>
</div>
<div id="zhuye">
    <form action="">
        <div>
            <label for="e-mail">邮箱</label>
            <input type="text" name="mail" id="youxiang">
        </div><br>
        <div>
            <label for="minghao">名号</label>
            <input type="text" name="name" id="minghao">
        </div><br>
        <div>
            <label for="phone">手机</label>
            <input type="text" name="phone" id="shouji">
        </div><br>
        <div>
            <label for="password">密码</label>
            <input type="text" name="password" id="mima">
            <span class="info">密码要求6-15位英文字母</span>
        </div>
        <br>
        <button id="anniu"  onclick="haha()">重设密码</button>
    </form>
</div>

</body>
</html>
<script>
    var pas = document.getElementById('mima');
    var  bb=0;
    pas.oninput=function () {
        var user1 = pas.value;
        var res1= /^[a-zA-Z_][0-9a-zA-Z_]{5,20}$/;
        var spn1 = pas.parentElement.getElementsByClassName('info')[0];
        if(res1.test(user1)){

            spn1.style.display="none";
        }else{
            spn1.style.display="inline-block";
            bb=bb+1;

        }

    }
    
    function haha() {

if(bb==0){
        var f=new FormData(document.forms[0]);
        fetch('/CoolReal/reset',{
        	 credentials: 'include',
        method:'POST',
                body:encodeURI(Array.from(f.entries()).map(el=>el.join('=')).join('&')),
                headers:
        {
            'content-type':'application/x-www-form-urlencoded;charset=utf-8'
        }
        })
        .then(function (res) {
            return res.text();
        })
                .then(function (rest) {

                    console.log(rest);
                    if(response.status==1){

                        window.location.href='../zgp/login.html';
                    }else   {
                        alert(response.message);
                    }

        });
        }else{
    alert("修改密码失败,请填写正确的密码");
}
    }
</script>